<template>
  <div>
    <div style="margin-left: 20px;margin-top: 20px">
      <el-button type="success" @click="chakska()">查看反馈回复</el-button>
    </div>
  <div style="margin-top: 20px;margin-left: 20px">
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="反馈信息">
        <el-input v-model="form.text"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">立即反馈</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
    <el-dialog
        title="查看反馈"
        :visible.sync="dialogVisible"
        width="30%"
        :before-close="handleClose">
      <span>
        <el-table
            :data="tableData"
            style="width: 100%">
      <el-table-column
          prop="text"
          label="反馈的问题"
          width="180">
      </el-table-column>
      <el-table-column
          prop="reply"
          label="得到的回复"
          width="180">
      </el-table-column>
    </el-table>
      </span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>

  </div>
</template>

<script>
export default {
  name: "fankui",
  data() {
    return {
      tableData: [],
      form: {
        text: '',
        token: window.localStorage.getItem("token"),
        name: 1,
      },
      dialogVisible: false

    }
  },
  methods: {
    async onSubmit() {
      console.log('submit!');
      const res = await this.$http.post('fankui/',this.form)
      console.log(res)
      if(res.status==201){
        this.$message.success("反馈成功")
      }
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
          .then(() => {
            done();
          })
          .catch(err => {
            console.log(err)
          });
    },
    async chakska(){
      this.dialogVisible = true
      const res =await this.$http.get('fankui/',{
         params: {
           "token":window.localStorage.getItem("token")
         }
       })
      this.tableData = res.data
    }
  }
}
</script>

<style scoped>

</style>
